package com.claire.ffmpegplayer;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.claire.ffmpegplayer.databinding.ActivityMainBinding;
import com.claire.ffmpegplayer.player.SurfaceViewPlayer;
import com.claire.ffmpegplayer.sdk.FFmpeg;

public class MainActivity extends AppCompatActivity {

    // Used to load the 'ffmpegplayer' library on application startup.

    private ActivityMainBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());

        // Example of a call to a native method
//        TextView tv = binding.sampleText;
//        tv.setText(stringFromJNI());
//        FFmpeg.player_OpenStream("test",null);

        SurfaceViewPlayer surfaceViewPlayer = new SurfaceViewPlayer(getApplicationContext(),"rtsp://10.21.0.62:554/PR0");
        System.out.println("addView");
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(1280, 720);
        surfaceViewPlayer.setLayoutParams(lp);

        LinearLayout layout = findViewById(R.id.layout);
        layout.addView(surfaceViewPlayer);
        System.out.println("addView");
    }


    /**
     * A native method that is implemented by the 'ffmpegplayer' native library,
     * which is packaged with this application.
     */
    public native String stringFromJNI();
}